package com.miaoxun.service.queue;

import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


public class ProducerManager {
   private static  DefaultMQProducer defaultMQProducer;

    public static DefaultMQProducer createProducer() {
        if (defaultMQProducer == null) {
            defaultMQProducer = new DefaultMQProducer("queue");
        }
        defaultMQProducer.setNamesrvAddr("localhost:9876");
        defaultMQProducer.shutdown();
        return defaultMQProducer;
    }

 private  static    DefaultMQPushConsumer defaultMQPushConsumer;
    public static DefaultMQPushConsumer createConsumer() {
        if (defaultMQPushConsumer == null) {
            defaultMQPushConsumer = new DefaultMQPushConsumer("queue");
        }

        defaultMQPushConsumer.setNamesrvAddr("localhost:9876");
        return defaultMQPushConsumer;
    }
}
